package com.example.controller;

import com.example.result.CodeMsg;
import com.example.result.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 张青卯
 * @date Created in 9:06 2019/2/19
 */
@Controller
@RequestMapping("/demo")
public class DemoController {
    @RequestMapping("/")
    @ResponseBody
    String home(){
        return "Hello World";
    }

    /**
     *  1.rest api json输出 2.页面
     */
    @RequestMapping("/hello")
    @ResponseBody
    public Result<String> hello(){
        return Result.success("hello,imooc");
    }

    @RequestMapping("/helloError")
    @ResponseBody
    public Result<String> helloError(){
        return Result.error(CodeMsg.SERVER_ERROR);
    }
}
